package com.mmp.common.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.mmp.common.bo.Message;

public class LogoutServlet extends BasicServlet {

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// the next two headers to handle the caching issues of ie
		// response.setHeader("Cache-Control", "no-cache, no-store");
		// response.setHeader("Pragma", "no-cache");

		request.logout();

		HttpSession session = request.getSession(false);
		Message prevSessionMsg = null;

		if (session != null) {
			// keep reference to the session message before invalidate to add to
			// new session
			prevSessionMsg = getMessage(request);
			session.invalidate();
		}
		setMessage(request, prevSessionMsg);
		sendRedirect(request, response, "LoginDisplay");
	}
}
